﻿using System.Collections.Generic;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MyCompany.WebCrawler.Repositories;

namespace MyCompany.WebCrawler.Test.RepositoryTest.Given_DatabaseWithLinks
{
    [TestClass]
    public class When_RemoveDublicates : Context
    {
        private Repository repository;
        private const string url1 = "http://google.com";
        private const string url2 = "http://bing.com";
        private List<string> links;

        public override void Arrange()
        {
            repository = new Repository();
            repository.Clean();
            repository.Save(url1);

            links = new List<string>()
                {
                    url1,
                    url2
                };
        }

        public override void Act()
        {
            links = repository.RemoveDuplicats(links);
        }

        [TestMethod]
        public void Then_NoDups()
        {
            links.Count.Should().Be(1);
            links[0].Should().Be(url2);
        }
    }
}